#include<stdio.h>
#include<math.h>
enum {N=100};


double g(double x)
{
	return x;
}
double f(double x)
{
	return x*x;
}
double integrate(double a,double b,double(*f)(double))
{
	double dx=(b-a)/N,sum=0;
	int i;
	for(i=0;i<N;i++)
	{
		sum+=(f(i*dx+a)+f((i+1)*dx+a))*dx/2;
	}
	return sum;
}
int main()
{

	printf("%.3f\n",integrate(0,1,f));
	printf("%.3f\n",integrate(0,1,g));
	printf("%.3f\n",integrate(0,1,sin));
	printf("%.3f\n",integrate(0,1,cos));
	printf("%.3f\n",integrate(0,1,exp));
	printf("%.3f\n",integrate(0,1,tan));
	return 0;
}